define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'apply/index',
                    add_url: 'apply/add',
                    edit_url: 'apply/edit',
                    del_url: 'apply/del',
                    multi_url: 'apply/multi',
                    table: 'apply'
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), sortable: true},
                        {field: 'apply_type', title: '类型',searchList:{"10":"小程序申请","20":"支付申请","30":"入驻申请","40":"代理申请","50":"实名认证"},formatter: Table.api.formatter.normal},
                        {field: 'applet_id', title: '小程序ID'},
                        {field: 'user_id', title: '用户ID'},
                        {field: 'status', title: '审核状态', operate: false,searchList: {"10":"待审核","20":"验证中","30":"已审核","40":"已驳回"}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }

    };
    return Controller;
});
